#pragma once
#include "Singleton.h"
#include "RobotBuilder.h"

class BuildingSceneContactListener: public b2ContactListener
{
public:
	BuildingSceneContactListener();

	void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);

	void SetSkipSolve(bool flag);

	bool m_skipSolve;
};


class Ground;
class Robot;
class BuildingScene :public Singleton<BuildingScene>
{
	friend Singleton;
private:
	// constructor.
	BuildingScene();

	// destructor.
	~BuildingScene();

public:
	void Initialize();

	bool ParseRobot(const char* xml, uint length);

	void GameStart();

	void GameEnd();

	// update
	void OnUpdate(float frameTime);

	// render
	void OnPreRender();

	void GenerateJoint();

	void SaveRobot2XML();

	BuildingSceneContactListener* GetContactListener();

	std::shared_ptr<RobotBuilder>	GetRobotBuilder();
	
private:
	std::shared_ptr<Ground>			m_Ground;

	std::shared_ptr<Robot>			m_BuildRobot;

	BuildingSceneContactListener	m_ContactListener;

	std::shared_ptr<RobotBuilder>	m_RobotBuilder;
};